from selenium.webdriver.common.by import By

from Pages import BasePage


class LoginPage(BasePage.Action):
    #用户名
    userid_loc = (By.XPATH,"//input[@type = 'text']")
    #密码
    password_loc = (By.XPATH,"//input[@type = 'password']")
    #登录按钮
    loginbutton_loc = (By.CSS_SELECTOR,".el-button--primary")
    #登录提示
    loginWarning_loc = (By.CSS_SELECTOR, "[class*='login-warn']")
    #同意服务协议及隐私政策
    checkBox_loc = (By.XPATH,"//span[text()='登录即代表您已阅读并同意']")

    # Action
    #打开浏览器
    def open(self):
        # self._open(self.base_url, self.pagetilte)
        self._open(self.base_url)
    #输入用户名
    def input_userid(self, userid):
        self.find_element(*self.userid_loc).send_keys(userid)
    #输入密码
    def input_password(self, password):
        self.find_element(*self.password_loc).send_keys(password)
    #勾选隐私政策
    def click_checkBox(self):
        if (self.find_element(*self.checkBox_loc)):
            self.find_element(*self.checkBox_loc).click()

    #点击登录
    def click_login(self):
        self.wait_loadingmask_disappear()
        self.find_element(*self.loginbutton_loc).click()
